package com.haipumi.actions;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;

import com.haipumi.beans.DataGrid;
import com.haipumi.beans.haipumi_chatInfo;
import com.haipumi.biz.IBackChatInfoBiz;
import com.haipumi.biz.impl.BackChatInfoBizImpl;
import com.opensymphony.xwork2.ActionSupport;

public class ChatInfoAction extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2085822435918372719L;

	IBackChatInfoBiz ibcib=new BackChatInfoBizImpl();
	
	DataGrid dg=new DataGrid();
	
	
	//暂时还没有用到，加spring的时候用
	public void setIbcib(IBackChatInfoBiz ibcib) {
		this.ibcib = ibcib;
	}

	public DataGrid getDg() {
		return dg;
	}

	public void setDg(DataGrid dg) {
		this.dg = dg;
	}
	
	

	@Override
	public String execute() throws Exception {
		String op=null;
		HttpServletRequest request=ServletActionContext.getRequest();
		HttpServletResponse response=ServletActionContext.getResponse();
		op=request.getParameter("op");
		if("findallchatinfo".equals(op)){			
			findallchatinfo(request,response);
		}
		
		return super.execute();
	}

	private void findallchatinfo(HttpServletRequest request,HttpServletResponse response){
		List<haipumi_chatInfo>chatinfolist=null;
		chatinfolist=ibcib.findAllChatInfo();
		int r=0;
		r=ibcib.countAllChatInfo();
		
		dg.setRows(chatinfolist);
		dg.setTotal(r);
	}
}
